package com.vogue.supplymall.shop.domain.service.impl;

import com.vogue.ssm.database.dao.BaseDao;
import com.vogue.supplymall.shop.domain.dao.ProductDetailsDao;
import com.vogue.supplymall.shop.domain.model.ProductDetails;
import com.vogue.supplymall.shop.domain.service.ProductDetailsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * The type Product details service.
 *
 * @aouthor: zhangliang
 * @date: Create in 2018-01-02
 */
@Service("productDetailsService")
public class ProductDetailsServiceImpl extends BaseServiceImpl<ProductDetails, Long> implements ProductDetailsService {

    @Resource
    private ProductDetailsDao productDetailsDao;

    /**
     * Instantiates a new Product details service.
     *
     * @param baseDao the base dao
     */
    public ProductDetailsServiceImpl(BaseDao<ProductDetails, Long> baseDao) {
        super(baseDao);
    }

    @Override
    public List<ProductDetails> findProductDetail(Integer type, Long id) {
        ProductDetails productDetails = new ProductDetails();
        productDetails.setProductid(id);
        productDetails.setType(type);
        return productDetailsDao.findProductDeta(productDetails);
    }

	@Override
	public ProductDetails findProductDetailsBySP(Long syscodeid, Long productid) {
		ProductDetails pd=new ProductDetails();
		
		List<ProductDetails> list=productDetailsDao.findProductDetailsBySP(syscodeid, productid);
		if(list.size()>0&&list.get(0)!=null) {
			pd=list.get(0);
		}
		
		return pd;
	}

	@Override
	public int delProductDetailsBySP(Long syscodeId, Long productId) {
		return productDetailsDao.delProductDetailsBySP(syscodeId, productId);
	}
    
}
